package com.z996.spring6;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidPooledConnection;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.sql.SQLException;

/**
 * 简述:<br>
 * 实验九: 引入外部文件
 *
 * @Author zfh18
 * @Date 2024-02-02 15:27
 * @Version 1.0
 **/
public class DIIntoConfigTest {
    private Logger logger = LoggerFactory.getLogger(DIIntoConfigTest.class);


    /**
     * @Description 根据id 和 类型获取
     * @Author zfh18
     * @Date 15:38 2024-02-02
     **/
    @Test
    public void testByClassAndId() throws SQLException {

        ApplicationContext ac = new ClassPathXmlApplicationContext("bean-DI-intoConfig.xml");
        DruidDataSource dds = ac.getBean(DruidDataSource.class);
        DruidPooledConnection connection = dds.getConnection();
        logger.info("打印结果:${}", connection);
    }


}
